Sharp Stuff
Switchblades Icepicks and german knives
Goth and Gore Gifts
Shop right now or else!
PHP Gallery
PHP Gallery is a free php image script.
Evil gear
Christmas is almost here

here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.

A simple one page cgi chat for a cgi-bin based chatroom

cgi perl chatroom chat
cgi-chat date added Jan 2013

#!/usr/bin/perl
#>---------------------------------------<#
#| Every
Chat 3.61 (rev. 1/20/01)         |#
#| Copyright (C) 1999 Matt Hahnfe
ld      |#
#>---------------------------------------<#

# This prog
ram is free software; you can redistribute it and/or modify
# it unde
r the terms of the GNU General Public License as published by
# the F
ree Software Foundation; either version 2 of the License, or
# (at yo
ur option) any later version.
#
# This program is distributed in the
 hope that it will be useful,
# but WITHOUT ANY WARRANTY; without eve
n the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICUL
AR PURPOSE.  See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software
# Fou
ndation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# The newest version of this software is always available at:

http://www.everysoft.com/everychat/

#>-----------------------------
----------<#
#| CONFIGURATION (MODIFY THIS SECTION)   |#
#>---------
------------------------------<#

# place the absolute path to your 
chat room message files
# here (include a trailing slash).

    $filep
ath='/home/hahnfld/public_html/messages/';

# place the file extenti
on of your chat room message files
# here, including the dot.  It is 
probably .htm or .html

    $filext='.html';

# setting this flag wil
l make messages scroll from top to
# bottom, making the script compat
ible with EVERY browser.
# See the readme.txt file under OPTIONS for 
more details!

    $iecompatible=0;

#>------------------------------
---------<#
#| Main Program                          |#
#| (all it d
oes is call subprograms)     |#
#>-----------------------------------
----<#

print "Content-type: text/html\nPragma: no-cache\n\n";
prin
t "<html><title></title><BODY BGCOLOR=#000080 TEXT=#FFFFFF>\n";
&getform;

if (&getoldfile) {
    &gettime;
    &printform;
    if ($form{'message'} 
ne "") { &printnewfile; }
    else { &printnoframes; }
}
else
{
    pri
nt "The room you entered <I>$form{'room'}</I> does not exist.<BR>\n";

    print "Tell the server administrator to check the file: <I>$filepath
$form{'room'}$filext</I>\n";
}
print "</font></body></html>\n";
exi
t(0);

#>---------------------------------------<#
#| Sub getform -
 reads form data         |#
#>---------------------------------------
<#

sub getform {
    $buffer = "";
    read(STDIN, $buffer, $ENV{'CONTE
NT_LENGTH'});
    @pairs=split(/&/,$buffer);
    foreach $pair (@pairs)
    
{
        @a = split(/=/,$pair);
        $name=$a[0];
        $value=$a[1];
        $value
 =~ s/\+/ /g;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($
1))/eg;
        $value =~ s/~!/ ~!/g;
        $value =~ s/\</\&lt\;/g;  # html t
ag removal (remove these lines to enable HTML tags in messages)
        $va
lue =~ s/\>/\&gt\;/g;  # html tag removal (remove these lines to enabl
e HTML tags in messages)
        $value =~ s/[\r\n]//g;
        push (@data,$nam
e);
        push (@data,$value);
    }
    %form=@data;
    %form;
}

#>------
---------------------------------<#
#| Sub getoldfile - reads old HTM
L       |#
#| messages file and returns 0 if not    |#
#| found or 1
 if found                   |#
#>------------------------------------
---<#

sub getoldfile {
    $form{'room'} =~ s/\W//g;
    return 0 unles
s open(HTMLOLD, "$filepath$form{'room'}$filext");
    @lines=<HTMLOLD>;

    close(HTMLOLD);
    return 1;
}

#>--------------------------------
-------<#
#| Sub gettime - reads system time       |#
#>------------
---------------------------<#

sub gettime {
    $now_string = localti
me;
    @thetime = split(/ +/,$now_string);
    @theclock = split(/:/,$the
time[3]);
    $ampm = 'am';
    if ($theclock[0] > 11)
    { $ampm = 'pm'; }

    if ($theclock[0] == 0)
    { $theclock[0] = 12; }
    if ($theclock[0] 
> 12)
    { $theclock[0] -= 12; }
    else
    { $theclock[0] += 0; }
}


#>---------------------------------------<#
#| Sub printform - prints
 new form       |#
#>---------------------------------------<#

sub
 printform {
    if ($form{'logoff'} eq '1')
    {
        print << "EOF";
        <
CENTER>Thank you for using EveryChat 3.61!</CENTER><BR><HR><FONT SIZE=
-1>
EOF
    }
    else
    {
        print << "EOF";
        <CENTER><TABLE CELLSPACI
NG=0 CELLPADDING=0>
        <TR><TD>
        <nobr><FORM ACTION="$ENV{'SCRIPT_NA
ME'}" METHOD="POST">
        Your message: <input name=username type=hidden
 value="$form{'username'}">
        <input name=room type=hidden value="$fo
rm{'room'}">
        <input type=text name=message size=35>
        <input type=
submit value="Post This">
        </form></nobr>
        </TD><TD>
        <nobr><FOR
M ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
        <input name=username 
type=hidden value="$form{'username'}">
        <input name=room type=hidden
 value="$form{'room'}">
        <input name=logoff type=hidden value=1>
        
<input type=hidden name=message value="Buh-Bye! I just logged off!">

        <input type=submit value="Logoff">
        </form></nobr>
        </TD></TR>

        </TABLE></CENTER><BR><HR>
        <FONT SIZE=-2>Hit "post" without enteri
ng a message to refresh the screen...</FONT><FONT SIZE=-1>
EOF
    }
}


#>---------------------------------------<#
#| Sub printnewfile -
 prints new HTML    |#
#| messages file                         |#
#
>---------------------------------------<#

sub printnewfile {
    $ne
wmessage = "<P><B>$form{'username'}</B> says,\"$form{'message'}\" ($th
etime[0] $theclock[0]:$theclock[1]$ampm)\n";
    open (NEW, ">$filepath$
form{'room'}$filext");
    print NEW "<HTML><HEAD><META HTTP-EQUIV=Refre
sh CONTENT=5><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY BGC
OLOR=#FFFFFF>\n";
    if ($iecompatible) {
        print NEW $newmessage;
        
print $newmessage;
        for ($i = 1; $i < 15; $i++)
        {
            print NEW "
$lines[$i]";
            print "$lines[$i]";
        }
        print NEW "<BR><FONT COLO
R=#FFFFFF>EveryChat (c) 1997-99 Matt Hahnfeld</FONT></BODY>\n";
    }
    
else {
        for ($i = 2; $i < 16; $i++)
        {
            print NEW "$lines[$i]";

            print "$lines[$i]";
        }
        print NEW $newmessage;
        print $newm
essage;
        print NEW "<BR><FONT COLOR=#FFFFFF><A NAME=END>EveryChat (c
) 1997-99 Matt Hahnfeld</A></FONT></BODY>\n";
    }
    close NEW;
}

#
>---------------------------------------<#
#| Sub printnoframes - ref
reshes screen  |#
#| if no messages are posted             |#
#>----
-----------------------------------<#

sub printnoframes {
    for ($i
 = 1; $i < 16; $i++)
    {
        print "$lines[$i]";
    }
}



Add your comment.













No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl